package com.stp.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.config.KafkaListenerEndpointRegistry;

@Slf4j
public class ConditionalKafkaListenerEndpointRegistry extends KafkaListenerEndpointRegistry {
    private boolean autostart = true;

    public ConditionalKafkaListenerEndpointRegistry() {
        this(true);
    }
    public ConditionalKafkaListenerEndpointRegistry(boolean autostart) {
        super();
        this.autostart = autostart;
    }

    @Override
    public void start() {
        if (autostart) {
            super.start();
        }else {
            log.warn("autostart=false，不启动kafka监听");
        }
    }
}
